package com.ruoyi.web.controller.disasterAssessment;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.disasterassessment.domain.MiningFaceModel;
import com.ruoyi.disasterassessment.dto.MiningFaceDto;
import com.ruoyi.disasterassessment.service.IMiningFaceModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 基础建模-采面建模Controller
 * 
 * @author hcc
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/disasterassessment/miningFace")
public class MiningFaceModelController extends BaseController
{
    @Autowired
    private IMiningFaceModelService miningFaceModelService;

    /**
     * 查询基础建模-采面建模列表
     */
    @PreAuthorize("@ss.hasPermi('disasterassessment:miningFace:list')")
    @GetMapping("/list")
    public TableDataInfo list(MiningFaceModel miningFaceModel)
    {
        startPage();
        List<MiningFaceModel> list = miningFaceModelService.selectMiningFaceModelList(miningFaceModel);
        return getDataTable(list);
    }

    /**
     * 导出基础建模-采面建模列表
     */
    @PreAuthorize("@ss.hasPermi('disasterassessment:miningFace:export')")
    @Log(title = "基础建模-采面建模", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MiningFaceModel miningFaceModel)
    {
        List<MiningFaceModel> list = miningFaceModelService.selectMiningFaceModelList(miningFaceModel);
        ExcelUtil<MiningFaceModel> util = new ExcelUtil<MiningFaceModel>(MiningFaceModel.class);
        util.exportExcel(response, list, "基础建模-采面建模数据");
    }

    /**
     * 获取基础建模-采面建模详细信息
     */
    @PreAuthorize("@ss.hasPermi('disasterassessment:miningFace:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(miningFaceModelService.selectMiningFaceModelById(id));
    }

    /**
     * 新增基础建模-采面建模
     */
    @PreAuthorize("@ss.hasPermi('disasterassessment:miningFace:add')")
    @Log(title = "基础建模-采面建模", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MiningFaceModel miningFaceModel)
    {
        return toAjax(miningFaceModelService.insertMiningFaceModel(miningFaceModel));
    }

    /**
     * 修改基础建模-采面建模
     */
    @PreAuthorize("@ss.hasPermi('disasterassessment:miningFace:edit')")
    @Log(title = "基础建模-采面建模", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MiningFaceModel miningFaceModel)
    {
        return toAjax(miningFaceModelService.updateMiningFaceModel(miningFaceModel));
    }

    /**
     * 删除基础建模-采面建模
     */
    @PreAuthorize("@ss.hasPermi('disasterassessment:miningFace:remove')")
    @Log(title = "基础建模-采面建模", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(miningFaceModelService.deleteMiningFaceModelByIds(ids));
    }
    /**
     * 查询基础建模-采面建模area列表
     */
    @PreAuthorize("@ss.hasPermi('disasterassessment:miningFace:list')")
    @GetMapping("/areaList")
    public TableDataInfo areaList() {
        startPage();
        List<MiningFaceDto> list = miningFaceModelService.getAreaList();
        return getDataTable(list);
    }
}
